﻿using System;

namespace Smart.Model
{
	public static class TimeHelper
	{
		private static readonly long epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).Ticks;
		/// <summary>
		/// 客户端时间
		/// </summary>
		/// <returns></returns>
		public static long ClientNow()
		{
			return (DateTime.UtcNow.Ticks - epoch) / 10000;
		}

		public static long ClientNowSeconds()
		{
			return (DateTime.UtcNow.Ticks - epoch) / 10000000;
		}

		/// <summary>
		/// 如果只是为了计算时间差没有必要进行除法计算
		/// </summary>
		public static long Ticks
		{
			get
			{
				return DateTime.UtcNow.Ticks;
			}
		}

		public static bool Reached(this long startTime,long interval)
		{
			return Ticks > startTime + interval;
		}

		public static long Now()
		{
			return ClientNow();
		}
    }
}